/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "dma.h"
#include "usart.h"
#include "gpio.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h"
#include <stdbool.h>
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN PV */
extern uint8_t usart2_rxdata[USARTRXMAXLEN], usart2_rxflag;
extern uint32_t usart2_rxlen;
uint8_t usart2_txdata[USARTRXMAXLEN] = {0xaa, 0xaa};
uint8_t pc_data[96];
uint8_t dtc_data[96];
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint8_t CrcAdd(uint8_t * buff, uint32_t len);
void PC_Data_Analysis();
void DTC_Data_Gather();
/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  	DTC_Data_Gather();
  	memcpy(usart2_txdata + 2, dtc_data, 36);
  	usart2_txdata[38] = CrcAdd(usart2_txdata, 38);
  	HAL_UART_Transmit(&huart2, usart2_txdata, 36 + 3, 1000);

  	if(usart2_rxflag == 1)
  	{
  		usart2_rxflag = 0;
  		if(usart2_rxdata[0] == 0xaa && usart2_rxdata[1] == 0xaa)
  		{
  			uint8_t crc = CrcAdd(usart2_rxdata, 38);
  			if(crc == usart2_rxdata[38])
  			{
  				memcpy(pc_data, usart2_rxdata + 2, 36);
					PC_Data_Analysis();
  			}
  		}
  	}
//  	PC_Data_Analysis();
 	HAL_Delay(100);
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLM = 25;
  RCC_OscInitStruct.PLL.PLLN = 336;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = 4;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
  {
    Error_Handler();
  }
}

/* USER CODE BEGIN 4 */
void DTC_Data_Gather()
{
	if(HAL_GPIO_ReadPin(OUT24_1_GPIO_Port, OUT24_1_Pin) == 0)//坐便冲洗按钮�??
	{
		dtc_data[0] = 1;
	}
	else
	{
		dtc_data[0] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_2_GPIO_Port, OUT24_2_Pin) == 0)//座便器水增压�??
	{
		dtc_data[1] = 1;
	}
	else
	{
		dtc_data[1] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_3_GPIO_Port, OUT24_3_Pin) == 0)//座便器排泄阀
	{
		dtc_data[2] = 1;
	}
	else
	{
		dtc_data[2] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_8_GPIO_Port, OUT24_8_Pin) == 0)//蹲便冲洗按钮�??
	{
		dtc_data[3] = 1;
	}
	else
	{
		dtc_data[3] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_9_GPIO_Port, OUT24_9_Pin) == 0)//蹲便器冲水阀
	{
		dtc_data[4] = 1;
	}
	else
	{
		dtc_data[4] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_10_GPIO_Port, OUT24_10_Pin) == 0)//蹲便器排泄阀
	{
		dtc_data[5] = 1;
	}
	else
	{
		dtc_data[5] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_11_GPIO_Port, OUT24_11_Pin) == 0)//车下灰水箱排泄阀
	{
		dtc_data[6] = 1;
	}
	else
	{
		dtc_data[6] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_4_GPIO_Port, OUT24_4_Pin) == 0)//�?�?箱加�??
	{
		dtc_data[7] = 1;
	}
	else
	{
		dtc_data[7] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_5_GPIO_Port, OUT24_5_Pin) == 0)//�?�?箱喷射器
	{
		dtc_data[8] = 1;
	}
	else
	{
		dtc_data[8] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_6_GPIO_Port, OUT24_6_Pin) == 0)//�?�?箱出口阀
	{
		dtc_data[9] = 1;
	}
	else
	{
		dtc_data[9] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_7_GPIO_Port, OUT24_7_Pin) == 0)//�?�?箱进口阀
	{
		dtc_data[10] = 1;
	}
	else
	{
		dtc_data[10] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_14_GPIO_Port, OUT24_14_Pin) == 0)//防冻排空�??�??
	{
		dtc_data[11] = 1;
	}
	else
	{
		dtc_data[11] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT1_GPIO_Port, OUT1_Pin) == 1)//WWT 0%    备用
	{
		dtc_data[12] = 1;
	}
	else
	{
		dtc_data[12] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT2_GPIO_Port, OUT2_Pin) == 1)//WWT 25%   备用
	{
		dtc_data[13] = 1;
	}
	else
	{
		dtc_data[13] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT3_GPIO_Port, OUT3_Pin) == 1)//WWT 50%   备用
	{
		dtc_data[14] = 1;
	}
	else
	{
		dtc_data[14] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT4_GPIO_Port, OUT4_Pin) == 0)//FWT 50%   备用
	{
		dtc_data[15] = 1;
	}
	else
	{
		dtc_data[15] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT5_GPIO_Port, OUT5_Pin) == 0)//FWT 75%   备用
	{
		dtc_data[16] = 1;
	}
	else
	{
		dtc_data[16] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT6_GPIO_Port, OUT6_Pin) == 1)//座便器故�??
	{
		dtc_data[17] = 1;
	}
	else
	{
		dtc_data[17] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT7_GPIO_Port, OUT7_Pin) == 1)//蹲便器故�??
	{
		dtc_data[18] = 1;
	}
	else
	{
		dtc_data[18] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT8_GPIO_Port, OUT8_Pin) == 1)//WWT75%
	{
		dtc_data[19] = 1;
	}
	else
	{
		dtc_data[19] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT9_GPIO_Port, OUT9_Pin) == 1)//WWT100%
	{
		dtc_data[20] = 1;
	}
	else
	{
		dtc_data[20] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT10_GPIO_Port, OUT10_Pin) == 0)//FWT25%
	{
		dtc_data[21] = 1;
	}
	else
	{
		dtc_data[21] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT11_GPIO_Port, OUT11_Pin) == 0)//FWT0%
	{
		dtc_data[22] = 1;
	}
	else
	{
		dtc_data[22] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT12_GPIO_Port, OUT12_Pin) == 0)//FWT 100% 备用
	{
		dtc_data[23] = 1;
	}
	else
	{
		dtc_data[23] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT13_GPIO_Port, OUT13_Pin) == 0)//防冻排空�??�??
	{
		dtc_data[24] = 1;
	}
	else
	{
		dtc_data[24] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_13_GPIO_Port, OUT24_13_Pin) == 0)//车下灰水箱排泄阀
	{
		dtc_data[25] = 1;
	}
	else
	{
		dtc_data[25] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_15_GPIO_Port, OUT24_15_Pin) == 0)//水系统�?��?
	{
		dtc_data[26] = 1;
	}
	else
	{
		dtc_data[26] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT24_12_GPIO_Port, OUT24_12_Pin) == 0)//备用
	{
		dtc_data[27] = 1;
	}
	else
	{
		dtc_data[27] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT14_GPIO_Port, OUT14_Pin) == 0)//X80-31
	{
		dtc_data[28] = 1;
	}
	else
	{
		dtc_data[28] = 0;
	}
	if(HAL_GPIO_ReadPin(OUT15_GPIO_Port, OUT15_Pin) == 0)//X80-32
	{
		dtc_data[29] = 1;
	}
	else
	{
		dtc_data[29] = 0;
	}

}
void PC_Data_Analysis()
{
	if(pc_data[0] == 1)//坐式便器排泄�??传感
	{
		HAL_GPIO_WritePin(IN3_3_1_GPIO_Port, IN3_3_1_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_1_GPIO_Port, IN3_3_1_Pin, 1);
	}
	if(pc_data[1] == 1)//座便器冲洗信�??
	{
		HAL_GPIO_WritePin(IN3_3_2_GPIO_Port, IN3_3_2_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_2_GPIO_Port, IN3_3_2_Pin, 1);
	}
	if(pc_data[2] == 1)//蹲便器排泄阀传感�??
	{
		HAL_GPIO_WritePin(IN3_3_6_GPIO_Port, IN3_3_6_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_6_GPIO_Port, IN3_3_6_Pin, 1);
	}
	if(pc_data[3] == 1)//蹲便冲洗信号
	{
		HAL_GPIO_WritePin(IN3_3_7_GPIO_Port, IN3_3_7_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_7_GPIO_Port, IN3_3_7_Pin, 1);
	}
	if(pc_data[4] == 1)//车下灰水箱排泄阀传感�??
	{
		HAL_GPIO_WritePin(IN3_3_9_GPIO_Port, IN3_3_9_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_9_GPIO_Port, IN3_3_9_Pin, 1);
	}
	if(pc_data[5] == 1)//车下灰水箱液位传感器
	{
		HAL_GPIO_WritePin(IN3_3_10_GPIO_Port, IN3_3_10_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_10_GPIO_Port, IN3_3_10_Pin, 1);
	}
	if(pc_data[6] == 1)//车下灰水箱安全液位传感器

	{
		HAL_GPIO_WritePin(IN3_3_13_GPIO_Port, IN3_3_13_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_13_GPIO_Port, IN3_3_13_Pin, 1);
	}
	if(pc_data[7] == 1)//防冻排空信号

	{
		HAL_GPIO_WritePin(IN3_3_16_GPIO_Port, IN3_3_16_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_16_GPIO_Port, IN3_3_16_Pin, 1);
	}
	if(pc_data[8] == 1)//气源压力�??�??
	{
		HAL_GPIO_WritePin(IN3_3_4_GPIO_Port, IN3_3_4_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_4_GPIO_Port, IN3_3_4_Pin, 1);
	}
//	HAL_GPIO_WritePin(IN3_3_4_GPIO_Port, IN3_3_4_Pin, 0);



	if(pc_data[9] == 1)//�?�?箱压力开�??
	{
		HAL_GPIO_WritePin(IN3_3_5_GPIO_Port, IN3_3_5_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_5_GPIO_Port, IN3_3_5_Pin, 1);
	}
	if(pc_data[10] == 1)//�?�?箱真空开�??
	{
		HAL_GPIO_WritePin(IN3_3_34_GPIO_Port, IN3_3_34_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_34_GPIO_Port, IN3_3_34_Pin, 1);
	}
	if(pc_data[11] == 1)//FWT25%
	{
		HAL_GPIO_WritePin(IN3_3_17_GPIO_Port, IN3_3_17_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_17_GPIO_Port, IN3_3_17_Pin, 1);
	}
	if(pc_data[12] == 1)//FWT0%
	{
		HAL_GPIO_WritePin(IN3_3_18_GPIO_Port, IN3_3_18_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_18_GPIO_Port, IN3_3_18_Pin, 1);
	}
	if(pc_data[13] == 1)//水系统故�??
	{
		HAL_GPIO_WritePin(IN3_3_20_GPIO_Port, IN3_3_20_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_20_GPIO_Port, IN3_3_20_Pin, 1);
	}
	if(pc_data[14] == 1)//FWT100%
	{
		HAL_GPIO_WritePin(IN3_3_21_GPIO_Port, IN3_3_21_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_21_GPIO_Port, IN3_3_21_Pin, 1);
	}
	if(pc_data[15] == 1)//FWT75%
	{
		HAL_GPIO_WritePin(IN3_3_22_GPIO_Port, IN3_3_22_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_22_GPIO_Port, IN3_3_22_Pin, 1);
	}
	if(pc_data[16] == 1)//FWT50
	{
		HAL_GPIO_WritePin(IN3_3_23_GPIO_Port, IN3_3_23_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_23_GPIO_Port, IN3_3_23_Pin, 1);
	}
	if(pc_data[17] == 1)//水�?�加�?信号

	{
		HAL_GPIO_WritePin(IN3_3_24_GPIO_Port, IN3_3_24_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_24_GPIO_Port, IN3_3_24_Pin, 1);
	}
	if(pc_data[18] == 1)//水�?�加�?故障

	{
		HAL_GPIO_WritePin(IN3_3_25_GPIO_Port, IN3_3_25_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_25_GPIO_Port, IN3_3_25_Pin, 1);
	}
	if(pc_data[19] == 1)//WWT100%
	{
		HAL_GPIO_WritePin(IN3_3_26_GPIO_Port, IN3_3_26_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_26_GPIO_Port, IN3_3_26_Pin, 1);
	}
	if(pc_data[20] == 1)//WWT75%
	{
		HAL_GPIO_WritePin(IN3_3_27_GPIO_Port, IN3_3_27_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_27_GPIO_Port, IN3_3_27_Pin, 1);
	}
	if(pc_data[21] == 1)//�?�?箱满
	{
		HAL_GPIO_WritePin(IN3_3_28_GPIO_Port, IN3_3_28_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_28_GPIO_Port, IN3_3_28_Pin, 1);
	}
	if(pc_data[22] == 1)//WWT50%
	{
		HAL_GPIO_WritePin(IN3_3_29_GPIO_Port, IN3_3_29_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_29_GPIO_Port, IN3_3_29_Pin, 1);
	}
	if(pc_data[23] == 1)//WWT25%
	{
		HAL_GPIO_WritePin(IN3_3_30_GPIO_Port, IN3_3_30_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_30_GPIO_Port, IN3_3_30_Pin, 1);
	}
	if(pc_data[24] == 1)//WWT0%
	{
		HAL_GPIO_WritePin(IN3_3_31_GPIO_Port, IN3_3_31_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_31_GPIO_Port, IN3_3_31_Pin, 1);
	}
	if(pc_data[25] == 1)//污物箱加�?信�?
	{
		HAL_GPIO_WritePin(IN3_3_32_GPIO_Port, IN3_3_32_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_32_GPIO_Port, IN3_3_32_Pin, 1);
	}
	if(pc_data[26] == 1)//污物箱加�?故�?
	{
		HAL_GPIO_WritePin(IN3_3_33_GPIO_Port, IN3_3_33_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_33_GPIO_Port, IN3_3_33_Pin, 1);
	}
	if(pc_data[27] == 1)//车下灰水箱排泄阀传感�??
	{
		HAL_GPIO_WritePin(IN3_3_11_GPIO_Port, IN3_3_11_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_11_GPIO_Port, IN3_3_11_Pin, 1);
	}
	if(pc_data[28] == 1)//车下灰水箱液位传感器
	{
		HAL_GPIO_WritePin(IN3_3_12_GPIO_Port, IN3_3_12_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_12_GPIO_Port, IN3_3_12_Pin, 1);
	}
	if(pc_data[29] == 1)//泄露�??�??
	{
		HAL_GPIO_WritePin(IN3_3_19_GPIO_Port, IN3_3_19_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_19_GPIO_Port, IN3_3_19_Pin, 1);
	}
	if(pc_data[30] == 1)//X80-39
	{
		HAL_GPIO_WritePin(IN3_3_35_GPIO_Port, IN3_3_35_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_35_GPIO_Port, IN3_3_35_Pin, 1);
	}
	if(pc_data[31] == 1)//备用
	{
		HAL_GPIO_WritePin(IN3_3_3_GPIO_Port, IN3_3_3_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_3_GPIO_Port, IN3_3_3_Pin, 1);
	}
	if(pc_data[32] == 1)//备用
	{
		HAL_GPIO_WritePin(IN3_3_8_GPIO_Port, IN3_3_8_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_8_GPIO_Port, IN3_3_8_Pin, 1);
	}
	if(pc_data[33] == 1)//X80-38
	{
		HAL_GPIO_WritePin(IN3_3_36_GPIO_Port, IN3_3_36_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_36_GPIO_Port, IN3_3_36_Pin, 1);
	}
	if(pc_data[34] == 1)//CPU+�?�?
	{
		HAL_GPIO_WritePin(IN3_3_14_GPIO_Port, IN3_3_14_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_14_GPIO_Port, IN3_3_14_Pin, 1);
	}
	if(pc_data[35] == 1)//CPU+�?�?
	{
		HAL_GPIO_WritePin(IN3_3_15_GPIO_Port, IN3_3_15_Pin, 0);
	}
	else
	{
		HAL_GPIO_WritePin(IN3_3_15_GPIO_Port, IN3_3_15_Pin, 1);
	}
}
uint8_t CrcAdd(uint8_t * buff, uint32_t len)
{
	uint8_t crc = 0;
	for(uint32_t i = 0; i < len; i++)
	{
		crc += buff[i];
	}
	return crc;
}
/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
